package com.ihd.ihardware.view.tzc.discovery.view;

import android.os.Bundle;

import com.ihd.ihardware.R;
import com.ihd.ihardware.common.AppConstans;
import com.ihd.ihardware.databinding.ActivityMsgsBinding;
import com.ihd.ihardware.pojo.MsgsRes;
import com.ihd.ihardware.view.tzc.discovery.viewmodel.MsgViewModel;

import cn.wowjoy.commonlibrary.base.BaseActivity;
import cn.wowjoy.commonlibrary.base.BaseConsumer;

public class MsgsActivity extends BaseActivity<ActivityMsgsBinding, MsgViewModel> {

    private String msgType;

    @Override
    protected void init(Bundle savedInstanceState) {
        mImmersionBar.statusBarDarkFont(true).init();
        binding.mtitlebar.setLeftBack(this);

        msgType = getIntent().getStringExtra("msgType");
        switch (msgType) {
            case "0":
                binding.mtitlebar.setTitle("通知");
                break;
            case "1":
                binding.mtitlebar.setTitle("评论");
                break;
            case "2":
                binding.mtitlebar.setTitle("点赞");
                break;
            case "3":
                binding.mtitlebar.setTitle("粉丝");
                break;
            default:
                break;
        }

        setRx(AppConstans.MSGS, new BaseConsumer<MsgsRes>(binding.stateLayout) {
            @Override
            protected void onStart() {
            }

            @Override
            protected void onSuccess(MsgsRes mLiveData) {
                viewModel.setComments(mLiveData.getData());
                if (mLiveData.getData().size() == 0)
                    binding.stateLayout.showEmptyView("暂无消息哦~");
            }

            @Override
            protected void onError(Throwable error) {
            }
        });

        binding.commentRV.setAdapter(viewModel.mDTAdapter);
        viewModel.msgs(msgType);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_msgs;
    }

    @Override
    protected Class getViewModelClass() {
        return MsgViewModel.class;
    }

}
